package com.zmn.oms.zmn.aop;

import com.zmn.oms.common.annotation.ZsNormalOrderWorkLog;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 类描述：普通单日志记录
 *
 * @author lujia
 * @date 2018/12/04 20:59
 */
@Aspect
@Component
@Order(-1)
public class ZsNormalOrderWorkLogAspect extends OrderWorkBaseLogAspect {

    /**
     * 设定切入点
     */
    @Pointcut("@annotation(com.zmn.oms.common.annotation.ZsNormalOrderWorkLog)")
    private void pointCutMethod() {
    }

    @Around("pointCutMethod() && @annotation(zsNormalOrderWorkLog)")
    public Object doLog(ProceedingJoinPoint joinPoint, ZsNormalOrderWorkLog zsNormalOrderWorkLog) throws Throwable {

        // 操作类型
        int logType = zsNormalOrderWorkLog.type();
        boolean beforeProceed = zsNormalOrderWorkLog.beforeProceed();
        boolean handleLog = zsNormalOrderWorkLog.handleLog();
        return super.doLog(joinPoint, logType, beforeProceed, handleLog);
    }
}
